In construction machines handling information-oriented construction, the position of a working machine needs to be accurately controlled, and thus supply of oil to a hydraulic actuator such as a hydraulic cylinder also needs to be accurately controlled. Therefore, a valve unit mounted in this type of construction machines is provided with a stroke detection device for detecting a stroke amount of a spool in a longitudinal direction. The stroke detection device includes a detection rod movably arranged with respect to a device main body, and a stroke detection unit that outputs a detection signal according to the stroke amount of the detection rod with respect to the device main body, for example, and is attached to the valve main body through the device main body in a state where a tip end surface of the detection rod is in contact with an end surface of the spool. A coil spring that biases the detection rod toward the end surface of the spool is provided between the device main body and the detection rod (for example, see Patent Literature 1).